class BillsMail < ApplicationMailer
  def welcome_email(user)
    @user = user
    @url = 'http://bills.geekfuns.com'
    mail(to: @user.email, subject: 'Welcome login Bills server')
  end

  def bills_notify(bill)
    @bill = Bill.find_by_id(bill.id)
    @bill_owner = @bill.bill_owner.name
    Rails.logger.debug "mail bill creater = #{@bill_owner}"
    @users = @bill.bill_members
    address = []
    @users.each do |user|
      address << user.email
    end
    Rails.logger.debug "email address = #{address}"
    mail(to: address,
         subject: 'bill notify',
         template_path: 'bills_mail',
         template_name: 'bills_email')

  end
end
